package cn.kgc.watch.web;

import cn.kgc.watch.entity.Cart;
import cn.kgc.watch.entity.CartShopping;
import cn.kgc.watch.entity.ResultInfo;
import cn.kgc.watch.service.CartService;
import cn.kgc.watch.service.CartShoppingService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
/**
 * 购物车
 */
@CrossOrigin
public class CartController {
    @Resource
    private CartService cartService;
    @Resource
    private CartShoppingService cartShoppingService;
    @GetMapping("findCart")
    public Cart findCart(Integer userId){
        return this.cartService.findCartByUserId(userId);
    }
    @PutMapping("dec")
    public void dec(@RequestBody CartShopping cartShopping){
        this.cartShoppingService.dec(cartShopping);
    }
    @PutMapping("inc")
    public void inc(@RequestBody CartShopping cartShopping){

        this.cartShoppingService.inc(cartShopping);
    }
    @DeleteMapping("remove")
    public void remove(Integer cartShoppingId){
        this.cartShoppingService.removeCartShopping(cartShoppingId);
    }

}
